﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace MvcMedicalProvider.DataAccess
{
    public class BaseDAO
    {
        public string ConnectionString
        {
            get
            {
                return ConfigurationManager.ConnectionStrings["MedicalProviderDbContext"].ConnectionString;
            }
        }

        protected virtual SqlConnection CreateSqlConnection()
        {
            return new SqlConnection(ConnectionString);
        }

        protected virtual SqlCommand CreateSqlCommand(string cmdText, SqlConnection sqlConnection)
        {
            return new SqlCommand(cmdText, sqlConnection);
        }

        protected virtual SqlCommand CreateSqlSpCommand(string spName, SqlConnection sqlConnection)
        {
            return new SqlCommand(spName, sqlConnection) { CommandType = CommandType.StoredProcedure };
        }

        protected SqlParameter[] CreateSqlParamaters(int numberOfParams)
        {
            return new SqlParameter[numberOfParams];
        }
    }
}